<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>菜单管理</title>
    <!-- 公共CSS,JS文件 -->
    <#include "../../admin/common/header.ftl"/>
</head>
<body>
<div class="container-fluid">
    <!-- 左右侧导航 -->
    <div class="row">
        <!-- 右侧导航 -->
        <div class="col-xs-12">
            <div class="panel">
                <div class="panel-heading">
                    <ol class="breadcrumb" style="margin-bottom: 2px;">
                        <li>首页</li>
                        <li>系统管理</li>
                        <li>菜单管理</li>
                        <div style="float: right; padding-bottom: 5px;"><a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="icon icon-refresh"></i></a></div>
                    </ol>
                </div>
                <!-- 添加mdal -->
                <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title">新增菜单</h4>
                            </div>
                            <div class="modal-body">
                                <form id="addForm" action="/admin/menu/save" method="post" class="form-horizontal">
                                    <input type="hidden" class="form-control" id="pId" name="pId" value="">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">上级菜单</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="pName" name="pName" value="">
                                        </div>
                                        <a href="#" class="btn btn-info" onclick="optMenu()">选择上级菜单</a>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单名称</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="name" name="name" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单类型</label>
                                        <div class="col-sm-5">
                                            <div class="radio">
                                                <label class="radio-inline">
                                                    <input type="radio" name="type" id="type" value="1">目录
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" name="type" id="type" value="2">菜单
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" name="type" id="type" value="3">按钮
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单URL</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="menuUrl" name="menuUrl" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">权限标识</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="permission" name="permission" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单图标</label>
                                        <div class="col-sm-5">
                                            <select class="chosen-icons form-control" name="icon" id="icon" data-value=""></select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单排序</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="sortNo" name="sortNo" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-5 col-sm-offset-3">
                                            <button type="submit" class="btn btn-primary">保存</button>
                                            <button type="button" class="btn btn-primary" id="resetBtn" >取消</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 修改modal -->
                <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title">修改菜单</h4>
                            </div>
                            <div class="modal-body">
                                <form id="editForm" action="/admin/menu/edit" method="post" class="form-horizontal">
                                    <input type="hidden" class="form-control" id="id" name="id" value="" />
                                    <input type="hidden" class="form-control" id="epId" name="pId" value="" >
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">上级菜单</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="epName" name="epName" value="" >
                                        </div>
                                        <a href="#" class="btn btn-info" onclick="optMenu()">选择上级菜单</a>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单名称</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="ename" name="name" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单类型</label>
                                        <div class="col-sm-5">
                                            <div class="radio">
                                                <label class="radio-inline">
                                                    <input type="radio" id="etype"  name="type" value="1">目录
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" id="etype"  name="type" value="2">菜单
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" id="etype"  name="type" value="3">按钮
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单URL</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="emenuUrl" name="menuUrl" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">权限标识</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="epermission" name="permission" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单图标</label>
                                        <div class="col-sm-5">
                                            <select class="chosen-icons form-control" id="eicon" name="icon" data-value="" ></select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">菜单排序</label>
                                        <div class="col-sm-5">
                                            <input type="text" class="form-control" id="esortNo" name="sortNo" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-5 col-sm-offset-3">
                                            <button type="submit" class="btn btn-primary">修改</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 加载菜单Modal -->
                <div class="modal fade" id="menuModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title">最多选择一个上级菜单项</h4>
                            </div>
                            <div class="modal-body">
                                <form id="menuForm" action="#" method="post" class="form-horizontal">
                                    <input type="hidden" class="form-control" id="id" name="id" value="" />
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">上级菜单</label>
                                        <div class="col-sm-5">
                                            <div class="col-sm-5">
                                                <ul id="menuTree" class="ztree"></ul>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-5 col-sm-offset-3">
                                            <button type="button" class="btn btn-primary" onclick="getSelectNodes();">确定</button>
                                            <button type="button" class="btn btn-primary" onclick="getSelectNodes();">关闭</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <!-- 搜索框 -->
                        <form action="/admin/menu/list" method="post">
                            <div class="col-xs-3">
                                <input type="text" id="searchParam" name="searchParam" value="${searchParam!}" class="form-control" placeholder="名称、编码">
                            </div>
                            <div class="col-xs-2">
                                <button class="btn btn-primary" type="submit">搜索</button>
                            </div>
                        </form>
                    </div>
                    <div id="toolbar" class="toolbox btn-group" style="padding-top:10px; padding-bottom:10px;">
                        <div class="tools-group">
                            <@shiro.hasPermission name="admin:menu:add">
                                <button class="btn btn-primary" data-toggle="modal" data-target="#addModal"><i class="icon icon-plus"></i>添加</button>
                            </@shiro.hasPermission>
                            <@shiro.hasPermission name="admin:menu:edit">
                                <button class="btn btn-success" onclick="optUpdate()"><i class="icon icon-edit"></i>修改</button>
                            </@shiro.hasPermission>
                            <@shiro.hasPermission name="admin:menu:delete">
                                <button class="btn btn-danger" onclick="optDelete()"><i class="icon icon-times"></i> 删除</button>
                            </@shiro.hasPermission>
                        </div>
                    </div>
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th><input type="checkbox" onclick="checkBox('ids',this.checked)"/></th>
                                <th>编号</th>
                                <th>上级菜单</th>
                                <th>菜单名称</th>
                                <th>菜单类型</th>
                                <th>菜单URL</th>
                                <th>权限标识</th>
                                <th>菜单图标</th>
                                <th>菜单排序</th>
                                <th>创建时间</th>
                                <th>修改时间</th>
                            </tr>
                        </thead>
                        <tbody>
                            <#if page.list??>
                                <#list page.list as menuDto>
                                    <tr>
                                        <th><input type="checkbox" class="checked_detect" value="${menuDto.id!?c }" name="ids"/></th>
                                        <th>${menuDto_index+1!}</th>
                                        <th>${menuDto.pName!}</th>
                                        <th>${menuDto.name!}</th>
                                        <th>
                                            <#if menuDto.type! == 1>目录</#if>
                                            <#if menuDto.type! == 2>菜单</#if>
                                            <#if menuDto.type! == 3>按钮</#if>
                                        </th>
                                        <th>${menuDto.menuUrl!}</th>
                                        <th>${menuDto.permission!}</th>
                                        <th><i class="${menuDto.icon!}"></i></th>
                                        <th>${menuDto.sortNo!}</th>
                                        <th>${menuDto.tsInsert!}</th>
                                        <th>${menuDto.tsUpdate!}</th>
                                    </tr>
                                </#list>
                            </#if>
                        </tbody>
                    </table>
                    <!-- 分页 start -->
                    <#include "../../admin/common/page.ftl"/>
                    <!-- 分页 end -->
                </div>
            </div>
        </div>
    </div>
<#include "../../admin/common/footer.ftl"/>
</div>
<#--导入menuList.js文件-->
<script src="/static/zui/js/menu/menuList.js"></script>
</body>
</html>